Under the hood, Python lists are not loosely linked structures but highly organized ArrayList. The core truth is: it occupies a contiguous block of memory addresses. What is stored here is not the objects themselves, but references to them references(which in C terms are pointers). This design enables unified management of heterogeneous dataโwhether RGB tuples or complex encryption keys (Key)โeach requiring only a fixed-size pointer slot.
Addressing Mathematics and Performance Trade-offs
- $O(1)$ Random Access: Using the formula $\text{Element Address} = \text{Base Address} + \text{Index} \times \text{Size}$, the CPU can locate any element instantly.
- Amortized Analysis: By using an over-allocation strategy, although a single insertion may cost $O(n)$, the total cost becomes $n + \sum_{j=0}^{\lg n} 2^j = 3n$, ensuring amortized $O(1)$ performance for appends.
- Insertion Limitation: As shown in Figure 8-2, inserting at any position requires shifting all subsequent pointers, resulting in $O(n)$ complexity.
Algorithm Comparison
Unlike ArrayList's indexing ($O(1)$), skip lists have $O(\log n)$ search complexity. At the heart of RSA lies the Euclidean algorithm, whose core is $gcd(a,0) = a$. These algorithms all operate within this compact memory space.